Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build libimobiledevice on Windows? #582

Open
smart2robot opened this issue Oct 24, 2017 · 29 comments
Open

How to build libimobiledevice on Windows? #582

smart2robot opened this issue Oct 24, 2017 · 29 comments

Comments

@smart2robot
Copy link

i want to use library of libimobiledevice on windows, and implements functions of export and backup ios.
i guess there must have methods to compile the libraries on windows,but how to do it?

@ivan
Copy link

ivan commented Oct 25, 2017

Maybe take a look at https://github.com/libimobiledevice-win32/libimobiledevice (note: I have not tested this)

@Mradr
Copy link

Mradr commented Oct 30, 2017

I am still surprised we don't have tools already setup to auto build for windows

@deakjahn
Copy link

deakjahn commented Oct 31, 2017

@Mradr: They're on NuGet (including wrappers for .NET), you just have to include them in your project if you use a compatible IDE. Ready to use, no need to compile.

@qmfrederik
Copy link
Contributor

We maintain a fork of libimobiledevice which provides binaries for Windows, macOS and Ubuntu. We also provide the NuGet package @deakjahn refers to.

We try to frequently rebase on top of the latest versions of libimobiledevice and keep the delta with 'vanilla' libimobiledevice small.

You can find the latest binaries at https://dev.azure.com/libimobiledevice-win32/imobiledevice-net/_build/results?buildId=264&view=logs. Click Artifacts > Binaries to download the binaries.

@oddgames-david
Copy link

oddgames-david commented Feb 27, 2019

@qmfrederik I've not been able to build that repo, been trying for 3 hours. First you get stuck with unable to load file errors due to the paths not pointing to the package include folders. Then you get an error with DEVICE_LOOKUP_USBMUX being undeclared.

Followed those instructions and when i try to resolve nuget for ideviceinstaller i get:
image

@qmfrederik
Copy link
Contributor

@oddgames-david We've moved from NuGet to VcPkg for the native (libimobiledevice) dependencies. If you just want to download the binaries, you could go to https://dev.azure.com/libimobiledevice-win32/imobiledevice-net/_build/results?buildId=419 where you can find them in the Artifacts folder.

Alternatively, https://github.com/libimobiledevice-win32/libimobiledevice-vs has a single Visual Studio solution for the core libimobiledevice parts (though ideviceinstaller isn't part of it, yet)

You can also cross-compile from Linux, I think that's how the maintainers of this project do it.

@nikias
Copy link
Member

nikias commented Feb 28, 2019

FYI I compile it with MinGW on Windows.

@oddgames-david
Copy link

@qmfrederik @nikias thanks for the info, i got it compiling with cygwin, been a bit of a learning curve.

@wangyuting-art
Copy link

@oddgames-david We've moved from NuGet to VcPkg for the native (libimobiledevice) dependencies. If you just want to download the binaries, you could go to https://dev.azure.com/libimobiledevice-win32/imobiledevice-net/_build/results?buildId=419 where you can find them in the Artifacts folder.

Alternatively, https://github.com/libimobiledevice-win32/libimobiledevice-vs has a single Visual Studio solution for the core libimobiledevice parts (though ideviceinstaller isn't part of it, yet)

You can also cross-compile from Linux, I think that's how the maintainers of this project do it.

I can't find Artifacts > Binaries in https://dev.azure.com/libimobiledevice-win32/imobiledevice-net/_build/results?buildId=419. Maybe it has changed?

@longeand
Copy link

I've tried compiling it with MinGW and the Cygwin terminal but am getting errors. It looks like Windows doesn't support gdb anymore? I'm trying again be installing a bunch of the dependencies using Cygwin's setup tool.... I did find gdb in Cygwin packages, now i need to figure out the correct paths to use during the config process. I would love to get libimobiledevice running on Windows.

@mexmer
Copy link

mexmer commented Jun 13, 2022

i did compile libimobile on windows with msys2

@MasterCna
Copy link

@mexmer Can please share your steps or make a repo for it ?

@mexmer
Copy link

mexmer commented Jul 11, 2022

i had installed msys from https://www.msys2.org/
inside msys i installed following packages
gcc python-devel openssl-devel automake autoconf
pacman will automatically take care of dependencies, so i'm listing only main packages
then i did compile packages in following order
libplist
libimobiledevice-glue
libusbmuxd
libimobiledevice

i don't need cython support, so when i got python error after running autogen.sh (for libplist and libimobile) i just did run
configure --without-cython
then compiled

@yuzhujiutian
Copy link

yuzhujiutian commented Mar 6, 2023

hi @mexmer

While I configure libplist ( environment: windows10 git bash, MINGW64, python-devel, pacman intalled )
./configure LIBS="-L/usr/lib/python3.11"

I got some errors as follows ( Why? I hope no errors. Thanks very much ^_^ ):

configure: Cython executable is '/usr/bin/cython'
checking for python3.11... (cached) /usr/bin/python
checking for a version of Python >= '2.1.0'... yes
checking for the distutils Python package... yes
checking for Python include path... <string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
-I/usr/include/python3.11
checking for Python library path... <stdin>:4: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<stdin>:4: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<stdin>:3: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<stdin>:3: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
<stdin>:2: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<stdin>:2: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
-L/usr/lib -lpython3.11
checking for Python site-packages path... <string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
/usr/lib/python3.11/site-packages
checking python extra libraries... <string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
-lintl -ldl
checking python extra linking flags... <string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead

checking consistency of all components of python development environment... no
configure: error: in '/E/embed_python_miniapp/gitbinbash_adb_python/tobuild/libplist':
configure: error:
  Could not link test program to Python. Maybe the main Python library has been
  installed in some non-standard library path. If so, pass it to configure,
  via the LIBS environment variable.
  Example: ./configure LIBS="-L/usr/non-standard-path/python/lib"
  ============================================================================
   ERROR!
   You probably have to install the development version of the Python package
   for your distribution.  The exact name of this package varies among them.
  ============================================================================

See 'config.log' for more details

@mexmer
Copy link

mexmer commented Mar 6, 2023

@yuzhujiutian as i mentioned in my previous post, i compile liplist (and also other libimobile projects) without python/cython support. i don't use this project under python at all. probly nikias will give you answer, but my assumption is, that it was simple not updated to compile with never versions of python.

@yuzhujiutian
Copy link

yuzhujiutian commented Mar 7, 2023

@nikias
Hi, nikia, thanks for sharing mentioning that the compilation was successful ( MinGW on Windows ).
Looking forward to sharing a little more information, such as compiled dependent modules, main steps, etc.

@mbparker
Copy link

mbparker commented Apr 5, 2023

I used to use the @qmfrederik 's project because it made things soooo much simpler. It seems that project has been abandoned though. It's far out of sync with this repo. The binaries for Windows that were last published don't work for device backups anymore. This left me with no choice but to build it myself - having read that the latest [unpublished] code does work.

The process to build this project on Windows would be far less painful with even basic documentation. What took 4 hours of trial and error and googling to accomplish, should have taken 30 mins. @mexmer provided enough clues I was able to get it going. However, it's far more involved when you are setting up a brand new environment for the first time. In my case, it's msys2 on a Windows 11 VM running on an Intel Mac.

I'm not sure if the maintainers here just don't like Windows devs, or if it's just a lack of resources willing to sit down and type out the prerequisites and steps, or some other reason. At any rate, the library is a great solution - if you can get it building.

Just my $0.02 - no disrespect to anyone was intended.

@mbparker
Copy link

mbparker commented Apr 5, 2023

@yuzhujiutian @MasterCna

Here is a breakdown of my environment and what I ended up doing to get the libs to build. I hope this saves someone a good chunk of time. I can't speak to whether this workflow is ideal, or even technically correct, but it worked for me.

Environment:
MSYS2 / MinGW on Windows 11 (Parallels VM on MacOS)
Downloaded from https://www.msys2.org/

Installed Packages (via built-in pacman):

  • gcc
  • automake
  • make
  • autoconf
  • pkgconf
  • python-devel
  • openssl
  • openssl-devel
  • libtool
  • git

Starting Directory:
/usr/src

Ordered Build Steps:

  • libplist

  •   git clone https://github.com/libimobiledevice/libplist.git
    
  •   cd libplist
    
  •   ./autogen.sh --without-cython
    
  •   make
    
  •   make install
    
  • libimobiledevice-glue

  •   git clone https://github.com/libimobiledevice/libimobiledevice-glue.git
    
  •   cd libimobiledevice-glue
    
  •   ./autogen.sh
    
  •   make
    
  •   make install
    
  • libusbmuxd

  •   git clone https://github.com/libimobiledevice/libusbmuxd.git
    
  •   cd libusbmuxd
    
  •   ./autogen.sh
    
  •   make
    
  •   make install
    
  • libimobiledevice

  •   git clone https://github.com/libimobiledevice/libimobiledevice.git
    
  •   cd libimobiledevice
    
  •   ./autogen.sh --without-cython OPENSSL_CFLAGS=-I/include/openssl OPENSSL_LIBS="-L/bin -lssl -lcrypto"
    
  •   make	
    

Notes:

  • I did not require cython. You'll need to install that dependency if you need to support it.
  • pacman will install all require sub-dependencies automatically. However, I've listed all the deps I have installed below.
  • Cloning the repos is important. (as opposed to downloading a zip of the source and unpacking it)
  • I honestly don't understand why I had to pass OPENSSL_CFLAGS and OPENSSL_LIBS when building libimobiledevice. If I didn't include this, make fails because ld.exe can't find the referenced OpenSSL imports. Perhaps someone can shed light on this part.
  • For my use case, only the 32bit DLLs were needed. I imagine the 64bit steps would be very similar.

Full Package Listing (deps of deps of deps...) - Not all are required for libimobiledevice!

  • autoconf-wrapper 20221207-1
  • autoconf2.13 2.13-5
  • autoconf2.69 2.69-2
  • autoconf2.71 2.71-1
  • automake-wrapper 20221207-1
  • automake1.11 1.11.6-6
  • automake1.12 1.12.6-6
  • automake1.13 1.13.4-7
  • automake1.14 1.14.1-6
  • automake1.15 1.15.1-4
  • automake1.16 1.16.5-1
  • base 2022.06-1
  • bash 5.2.015-1
  • bash-completion 2.11-3
  • brotli 1.0.9-8
  • bsdtar 3.6.2-3
  • bzip2 1.0.8-4
  • ca-certificates 20230311-1
  • coreutils 8.32-5
  • curl 7.88.1-1
  • dash 0.5.12-1
  • db 5.3.28-4
  • diffutils 3.9-1
  • file 5.44-5
  • filesystem 2023.02.07-1
  • findutils 4.9.0-3
  • gawk 5.2.1-2
  • gcc-libs 11.3.0-3
  • gdbm 1.23-1
  • getent 2.18.90-4
  • gettext 0.21-2
  • git 2.40.0-1
  • gmp 6.2.1-2
  • gnupg 2.2.41-1
  • grep 1~3.0-6
  • gzip 1.12-2
  • heimdal 7.8.0-3
  • heimdal-libs 7.8.0-3
  • inetutils 2.4-1
  • info 7.0.2-1
  • less 629-1
  • libargp 20110921-4
  • libasprintf 0.21-2
  • libassuan 2.5.5-2
  • libbz2 1.0.8-4
  • libcbor 0.10.2-1
  • libcrypt 2.1-4
  • libcurl 7.88.1-1
  • libdb 5.3.28-4
  • libedit 20221030_3.1-1
  • libexpat 2.5.0-1
  • libffi 3.4.4-1
  • libfido2 1.13.0-1
  • libgcrypt 1.10.1-5
  • libgdbm 1.23-1
  • libgettextpo 0.21-2
  • libgnutls 3.8.0-1
  • libgpg-error 1.46-2
  • libgpgme 1.18.0-4
  • libhogweed 3.8.1-1
  • libiconv 1.17-1
  • libidn2 2.3.4-2
  • libintl 0.21-2
  • libksba 1.6.3-1
  • libltdl 2.4.7-3
  • liblz4 1.9.4-1
  • liblzma 5.4.1-1
  • libnettle 3.8.1-1
  • libnghttp2 1.52.0-1
  • libnpth 1.6-1
  • libopenssl 3.1.0-1
  • libp11-kit 0.24.1-4
  • libpcre 8.45-3
  • libpcre2_8 10.42-1
  • libpsl 0.21.2-1
  • libreadline 8.2.001-3
  • libsqlite 3.41.1-1
  • libssh2 1.10.0-3
  • libtasn1 4.19.0-1
  • libtool 2.4.7-3
  • libunistring 1.1-2
  • libutil-linux 2.35.2-3
  • libxml2 2.10.3-3
  • libxslt 1.1.37-1
  • libzstd 1.5.4-1
  • m4 1.4.19-2
  • make 4.4.1-1
  • mingw-w64-i686-binutils 2.40-2
  • mingw-w64-i686-brotli 1.0.9-5
  • mingw-w64-i686-ca-certificates 20230311-1
  • mingw-w64-i686-crt-git 10.0.0.r234.g283e5b23a-1
  • mingw-w64-i686-expat 2.5.0-1
  • mingw-w64-i686-gcc 12.2.0-10
  • mingw-w64-i686-gcc-libs 12.2.0-10
  • mingw-w64-i686-gettext 0.21.1-1
  • mingw-w64-i686-gmp 6.2.1-5
  • mingw-w64-i686-gnutls 3.8.0-1
  • mingw-w64-i686-headers-git 10.0.0.r234.g283e5b23a-1
  • mingw-w64-i686-isl 0.25-1
  • mingw-w64-i686-libffi 3.4.4-1
  • mingw-w64-i686-libiconv 1.17-3
  • mingw-w64-i686-libidn2 2.3.4-1
  • mingw-w64-i686-libplist 2.2.0-6
  • mingw-w64-i686-libtasn1 4.19.0-1
  • mingw-w64-i686-libunistring 1.1-1
  • mingw-w64-i686-libwinpthread-git 10.0.0.r234.g283e5b23a-1
  • mingw-w64-i686-mpc 1.3.1-1
  • mingw-w64-i686-mpfr 4.2.0-1
  • mingw-w64-i686-nettle 3.8.1-1
  • mingw-w64-i686-openssl 3.1.0-1
  • mingw-w64-i686-p11-kit 0.24.1-5
  • mingw-w64-i686-windows-default-manifest 6.4-4
  • mingw-w64-i686-winpthreads-git 10.0.0.r234.g283e5b23a-1
  • mingw-w64-i686-zlib 1.2.13-3
  • mingw-w64-i686-zstd 1.5.4-1
  • mintty 1~3.6.3-1
  • mpdecimal 2.5.0-1
  • mpfr 4.2.0-2
  • msys2-keyring 1~20230316-1
  • msys2-launcher 1.5-1
  • msys2-runtime 3.4.6-1
  • nano 7.2-1
  • ncurses 6.4-1
  • nettle 3.8.1-1
  • openssh 9.3p1-1
  • openssl 3.1.0-1
  • openssl-devel 3.1.0-1
  • p11-kit 0.24.1-4
  • pacman 6.0.2-1
  • pacman-contrib 1.8.2-1
  • pacman-mirrors 20221016-1
  • perl 5.36.0-1
  • perl-Authen-SASL 2.16-3
  • perl-Clone 0.46-1
  • perl-Convert-BinHex 1.125-2
  • perl-Encode-Locale 1.05-2
  • perl-Error 0.17029-1
  • perl-File-Listing 6.15-1
  • perl-HTML-Parser 3.81-1
  • perl-HTML-Tagset 3.20-3
  • perl-HTTP-Cookies 6.10-2
  • perl-HTTP-Daemon 6.16-1
  • perl-HTTP-Date 6.05-1
  • perl-HTTP-Message 6.44-1
  • perl-HTTP-Negotiate 6.01-3
  • perl-IO-HTML 1.004-2
  • perl-IO-Socket-SSL 2.081-1
  • perl-IO-Stringy 2.113-1
  • perl-LWP-MediaTypes 6.04-1
  • perl-MIME-tools 5.510-1
  • perl-MailTools 2.21-1
  • perl-Net-HTTP 6.22-1
  • perl-Net-SMTP-SSL 1.04-2
  • perl-Net-SSLeay 1.92-4
  • perl-TermReadKey 2.38-5
  • perl-TimeDate 2.33-2
  • perl-Try-Tiny 0.31-1
  • perl-URI 5.17-2
  • perl-WWW-RobotRules 6.02-2
  • perl-libwww 6.67-1
  • pinentry 1.2.1-1
  • pkgconf 1.9.4-1
  • python 3.11.2-1
  • python-devel 3.11.2-1
  • rebase 4.5.0-2
  • sed 4.9-1
  • tar 1.34-3
  • tcl 8.6.12-1
  • time 1.9-3
  • tzcode 2022g-1
  • util-linux 2.35.2-3
  • wget 1.21.3-2
  • which 2.21-4
  • xz 5.4.1-1
  • zlib 1.2.13-1
  • zlib-devel 1.2.13-1
  • zstd 1.5.4-1

@mexmer
Copy link

mexmer commented Apr 5, 2023

thanks for thorough guide. i would definetly recommend using msys2 too.

@didix21
Copy link

didix21 commented Apr 20, 2023

Is there any plan for moving from MSYS2 to Native Windows build using Visual Studio for example?

@Shyamal-Shah
Copy link

Hi @mbparker, Thanks for the guide, but I am getting the following errors while executing make on libimobiledevice.

make[3]: Entering directory '/home/user/libimobiledevice/3rd_party/libsrp6a-sha512'
  CC       t_conv.lo
  CC       t_math.lo
t_math.c:36:11: fatal error: openssl/opensslv.h: No such file or directory
 # include "openssl/opensslv.h"
           ^~~~~~~~~~~~~~~~~~~~

I have added the flags you mentioned, and I have checked the path '/usr/include/openssl' the file exists.

@mbparker
Copy link

mbparker commented May 12, 2023

@Shyamal-Shah Not sure what your problem is exactly just from that. I can tell you that I wen't to build the 64bit version last night and encountered all sorts of problems. One of which was very similar to yours. The only way that it would build for me was to uninstall MSYS2 and start with a fresh install - adding the prerequisites using a checklist. Honestly, not sure why it worked fine after that. It seemed to be an identical environment (except that I used the 64bit toolchain).

It's much more challenging to build this repo on Windows than Linux or even macOS.

If I can get enough free time, I'll run through the whole exercise again and double check the build steps.

If you're in a pinch, you can download the repo's CI binaries - but that's not solving the problem long term obviously.

Not much help, sorry.

@nikias
Copy link
Member

nikias commented May 12, 2023

Just leaving this here: https://github.com/libimobiledevice/libimobiledevice/actions

@mbparker
Copy link

mbparker commented May 12, 2023

@nikias Derp - I stand corrected. I should have have looked at the artifacts, not just the build jobs. Previous comment updated. Thanks.

@Shyamal-Shah
Copy link

Hi @mbparker, thanks solved the errors with the same steps (After a clean install of MSYS2).
I was wondering if we could build the iFuse in the same steps and access the files of the apps with file sharing enabled. Please let me know if you have got any success with that.

@mbparker
Copy link

@Shyamal-Shah I don't use iFuse, but as far as I know it can't work on Windows since FUSE only exists for Linux and macOS. It's been a long time since I looked into that though. You can create a virtual filesystem on Windows, but when I investigated that, it was quite complicated to do.

@mexmer
Copy link

mexmer commented May 12, 2023

ifuse subsystem is not available on windows, but you can build your own filesystem browser on top of housearresst service, and afc service, so that's not big deal.

@Shyamal-Shah
Copy link

Shyamal-Shah commented May 16, 2023

Hi @mbparker, thanks to you i am able to use libimobiledevice however, I noticed that ideviceinstaller is not part of this repo and I need to compile it separately. Do you have any steps for that?
I tried compiling it but no luck there as well. It requires 'libzip-dev' package but I am not able to find it and install it on MSYS. Could you please help in that matter?
I got the following error while running autogen:

checking for libzip >= 0.10... no
configure: error: Package requirements (libzip >= 0.10) were not met:
Package 'libzip', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables libzip_CFLAGS
and libzip_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

@nikias
Copy link
Member

nikias commented May 16, 2023

I am using a static libzip to build it, check the workflow here:
https://github.com/libimobiledevice/ideviceinstaller/actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests